home *** CD-ROM | disk | FTP | other *** search
- /************************************************/
- /* Sample DLL's */
- /* Copyright © Vincent Parsons 1989. */
- /************************************************/
- /* DLL code for MPW C 3.0 or THINK C 4.0 */
- /* with Excel for the Macintosh 2.2 */
- /* and Microsoft C 5.1 */
- /* with Excel for Windows 2.1 */
- /************************************************/
- /* SampKKK is an example of two data type K */
- /* inputs and one data type K output. The */
- /* output is the complex product of the */
- /* two type K inputs intrepreted as complex */
- /* numbers. */
- /************************************************/
- /* =REGISTER("SampDLLs","SampKKK","KKK") */
- /* for both the Mac and the PC. */
- /************************************************/
- /*
- Note that the complex number is passed
- as FP * c1 on the Mac and on the PC.
-
- The function type is pascal FP * on the Mac
- and FP far * far pascal on the PC.
-
- On the Mac the returned value is c1 (the
- pointer to the FP result) and the answer
- has been stored in the Excel buffer used
- by the input variable.
-
- On the PC the answer is stored in a static
- variable and the returned value is a pointer
- to that static value.
-
- This was done so the REGISTER command was
- the same in the PC and the Mac.
- */
- /************************************************/
-
- #include "DLL.h"
-
- typedef struct fp {
- unsigned short rows;
- unsigned short columns;
- double64 array[2];
- } FP;
-
- #if applec
- #include <Types.h>
-
- #elif MSDOS
- #include <windows.h>
-
- #endif
-
- #if THINK_C
- pascal FP * main(FP * k1, FP * k2); /* prototype */
-
- pascal FP * main(k1, k2)
- FP * k1;
- FP * k2;
-
- #elif applec
- pascal FP * SampKKK(FP * k1, FP * k2)
-
- #elif MSDOS
- FP far * far pascal SampKKK(FP far * k1, FP far * k2)
- #endif
- {
- #if applec | THINK_C
- FP answer; /* Automatic variable */
- #elif MSDOS
- static FP answer;
- #endif
-
- answer.array[0] = (k1->array[0] * k2->array[0]) - (k1->array[1] * k2->array[1]);
- answer.array[1] = (k1->array[0] * k2->array[1]) + (k1->array[1] * k2->array[0]);
- answer.rows = k1->rows;
- answer.columns = k1->columns;
-
- #if applec | THINK_C
- * k1 = answer; /* Store value in Excel data buffer since static */
- /* variables are not permitted in MPW code resources */
- return ( k1 );
- #elif MSDOS
- return( (FP far *)&answer );
- #endif
- }
-
- /************************************************/
-
-